# Author: yingjie.liu@thomsonreuters.com
# DateTime: 2011-05-02 15:31:22

#=========examples===========
## hash table
#my %src=(
#	"a"=>1,
#	"b"=>2,
#);
#foreach my $url (values %src){
#foreach my $key (keys %src){
#	my $url=$src{$key};
#foreach $key (sort (keys(%grades))) {
#foreach $key (sort {$a cmp $b} (keys(%grades))) {
#foreach my $gbm (sort {$a <=> $b} keys %bitmap2sr){


## read file
# open(FILE,"$filename") || die("could not open $filename\n");
# while($line=<FILE>){
# close(FILE);

## write file
# open(FILE,">$filename") || die("could not open $filename\n");
# append
# open(FILE,">>$filename") || die("could not open $filename\n");
# print FILE $something;

## datetime
#my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
#my $dt=sprintf("%4d-%02d-%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec);

## read input param
# my $keyword="defaltvalue";
# die("usage:$0 <>") if @ARGV < 1;
# $keyword=$ARGV[0] if @ARGV >0;

## new process
#my $ProcessObj;
#Win32::Process::Create($ProcessObj, "C:\WINDOWS\system32\cmd.exe", "cmd /k C:\perl\bin\perl.exe $cmd -u \"$url\" -k $keyword", 0, DETACHED_PROCESS,".")|| die("process create failed!");
#print $ProcessObj->GetProcessID(),"\n";

##array
#push @array, $value; 
#$count=$#array;

##re
# $multi_lines =~ m/.../s 
#Options are:
#
#    m   Treat string as multiple lines.
#    s   Treat string as single line. (Make . match a newline)
#    i   Do case-insensitive pattern matching.
#    x   Use extended regular expressions.
#    p   When matching preserve a copy of the matched string so
#        that ${^PREMATCH}, ${^MATCH}, ${^POSTMATCH} will be defined.
#    o   Compile pattern only once.
# 
#

## split, join
#@items=split /,/,$line;
#chomp(@items);
#join ",",@items[$s_ric_begin..$s_ric_end]

## string cmp
#$str eq "something"
#"$str" ne "something"

# $A=1;
# $B=A;
# $$B eq 1

#begin



package Bit;
use base qw(Exporter);
use overload ('0+' => 'to_number',
  		'""'=> 'as_string');
my $debug=1;
our $enum_size=3;

sub new{
  my $this={};
  bless $this;
  $this->{'m_value'}=$_[1];
  print "new Bit: $this->{'m_value'}\n" if $debug;
  return $this;
}

sub to_number{
  my ($this)=@_;
  return $this->{'m_value'};
}
sub as_string{
  return $_[0]->{'m_value'};
}

#our @EXPORT=qw(debug);
unless(caller){
#unit test code
  $b1=Bit->new(2);
  $b=new Bit(1);
  print "Bit: $b->{'m_value'}\n";
  print "Bit: $b\n";
  print int($b)+1;
};



1;
